package io.renren.wh.order.util;

import java.lang.reflect.Field;

public class LogUtil
{

	private static boolean debuMode = true;

	public static void setLog(boolean mode)
	{
		debuMode = mode;
	}

	public static void i(String TAG, String msg)
	{
		if (debuMode)
		{
			 System.out.println(TAG + "\n" + msg);
		}

	}

	public static void e(String TAG, String msg)
	{
		if (debuMode)
		{
			 System.err.println(TAG + "\n" + msg);
		}

	}

	public static String getInfo()
	{
		if (debuMode)
		{
			StringBuffer sb = new StringBuffer();
			StackTraceElement[] stacks = new Throwable().getStackTrace();
			// sb.append("[").append(StringUtil.getDateTime()).append("]");//在log4j打时间
			sb.append("[").append(stacks[1].getClassName()).append("]");
			sb.append("[").append(stacks[1].getMethodName());
			sb.append(" ").append(stacks[1].getLineNumber()).append(" line]");
			return sb.toString();
		}
		return "";
	}
	
	public static void showClassNameVlaue(Class cl)
	{
		Field[] f = cl.getDeclaredFields();
		for (Field fie : f)
		{
			try
			{
				System.out.println(fie.getName()+">>"+fie.get(fie.getName()));
			} catch (IllegalArgumentException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
